import java.util.*;
//排序+二分模板
public class code2_2 {
    public static int n,l,r;
    public static int[] arr;
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        n = sc.nextInt();l =sc.nextInt();r=sc.nextInt();
        arr = new int[n];
        for(int i=0;i<n;i++) arr[i] = sc.nextInt();
        Arrays.sort(arr);
        long ret = 0;
        //二分(先固定大的数)
        for(int i=1;i<n;i++) {
            int L,R;
            //左端点
            int left=0,right=i-1;
            while(left<right) {
                int mid = (left+right)/2;
                if(arr[i]-arr[mid]<=r) right = mid;
                else left = mid+1;
            }
            if(arr[i]-arr[left]<=r) L=left;
            else L = left+1;
            //右端点
            left=0;right=i-1;
            while(left<right) {
                int mid = (left+right+1)/2;
                if(arr[i]-arr[mid]>=l) left = mid;
                else right = mid-1;
            }
            if(arr[i]-arr[left]>=l) R=left;
            else R = left-1;

            if(R>=L) ret += R-L+1;
        }
        System.out.print(ret);
    }
}